<template>
	<view>
		<!-- 搜索导航栏 -->
		<view class="Wish-list-background">
			<i class="Wish-list-icon-01" @click="goBack"></i>
			<text class="Wish-list-text">心愿单</text>
			<i class="Wish-list-icon-02" @click="card"></i>
		</view>
		<view class="Search-Navigation-backgeound"></view>
		<view class="fictitious">
			<!-- No-wish-list 视图 -->
			<view v-if="isWishListEmpty" class="No-wish-list">
				<view class="No-wish-list-background"></view>
				<text class="No-wish-list-txt">心愿单是空的,快去逛逛吧</text>
			</view>
			<!-- 心愿单项目视图 -->
			<view v-else class="Wish-list-items-background" v-for="(item,i) in xinyuandan" :key="i" @click="tuijian(i)">
				<view class="Wish-list-items-picture">
					<!-- 在这里添加项目图片 -->
					<image :src="item.product.image[0]" class="jb"></image>
				</view>
				<view class="Product-details-background">
					<text class="Product-details-txt">{{ item.product.description }}</text>
					<text class="Product-details-Price">￥{{ item.product.attributes.price }}</text>
					<view class="Operation-buttons-background">
						<view class="">
							<!-- 在这里添加其他按钮 -->
						</view>
						<view class="Operation-buttons">
							<text class="Entering-the-store">进店</text>
							<text class="Entering-the-store">找相似</text>
							<i class="Operation-buttons-icon"></i>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(){
			this.request("/InsertProductFavoritesService/selectProductFavori", "post",this.data).then(
				(res) => {
					console.log(res);
					this.xinyuandan = res.data.result
					console.log(this.xinyuandan[2]);
			
				}).catch((err) => {
				console.log(err);
			});
		},
		
		data() {
			return {
				xinyuandan:[],
				data: {
				    userId: this.userId = uni.getStorageSync('id'),
				    productId: null,
				    favoritestatus: null,
				  },
				wishlistItems: [{
						id: 1,
						name: '商品 1',
						price: '¥100',
						image: '../../static/img/product1.png'
					},
					{
						id: 2,
						name: '商品 2',
						price: '¥200',
						image: '../../static/img/product2.png'
					}
				] // 用于保存心愿单项目的数组
			};
		},
		computed: {
			isWishListEmpty() {
				return this.wishlistItems.length === 0;
			}
		},
		methods: {
			tuijian(e){
				uni.navigateTo({
				url:"/pages/Productdetails/ProductDetails?productId="+this.xinyuandan[e].product.productId
				})	
			},
			// 返回上一页
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			card() {
				uni.navigateTo({
					url: "/pages/Productdetails/Cart"
				});
			}
		}
	};
</script>

<style>
	.jb{
		width: 300rpx;
		height: 300rpx;
	}
	.Wish-list-background {
		width: 100%;
		height: 150rpx;
		background-color: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 40rpx;
		position: fixed;
		top: 0rpx;
	}

	.Wish-list-icon-01,
	.Wish-list-icon-02 {
		width: 90rpx;
		height: 90rpx;
		display: flex;
		align-items: center;
		background-image: url("../../static/icon/retuen.png");
		background-repeat: no-repeat;
		background-size: cover;
		margin-left: 20rpx;
	}

	.Wish-list-icon-02 {
		width: 80rpx;
		height: 80rpx;
		margin-right: 20rpx;
		background-image: url("../../static/img/gouwuche.png");
	}

	.Search-Navigation-backgeound {
		width: 100%;
		height: 150rpx;
	}

	.fictitious {
		width: 100%;
		height: 1800rpx;
		background-color: #f6f6f6;
	}

	.No-wish-list {
		width: 500rpx;
		height: 500rpx;
		margin: 50rpx auto;
		text-align: center;
	}

	.No-wish-list-background {
		width: 300rpx;
		height: 300rpx;
		margin: 20rpx auto;
		background-image: url("../../static/icon/Order icon.png");
		background-repeat: no-repeat;
		background-size: cover;
	}

	.No-wish-list-txt {
		display: block;
		font-size: 40rpx;
		color: #ccc;
		margin-top: 70rpx;
	}

	.Wish-list-items-background {
		width: 100%;
		height: 400rpx;
		background-color: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 30rpx;
	}

	.Wish-list-items-picture {
		width: 300rpx;
		height: 300rpx;
		border: 1rpx solid black;
		margin-left: 25rpx;
	}

	.Product-details-background {
		width: 380rpx;
		height: 300rpx;
		background-color: antiquewhite;
		margin-right: 20rpx;
	}

	.Product-details-txt {
		display: block;
		width: 330rpx;
		height: 90rpx;
	
		margin: auto;
	}

	.Product-details-Price {
		display: block;
		width: 180rpx;
		height: 80rpx;
	
		margin-top: 12rpx;
		margin-left: 20rpx;
	}

	.Operation-buttons-background {
		width: 380rpx;
		height: 120rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.Operation-buttons {
		width: 300rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
	}

	.Entering-the-store {
		width: 100rpx;
		height: 60rpx;
		border: 1rpx solid black;
		display: block;
		margin: auto;
		border-radius: 40rpx;
		text-align: center;
		line-height: 60rpx;
	}

	.Operation-buttons-icon {
		width: 50rpx;
		height: 50rpx;
		border: 1rpx solid black;
		border-radius: 50%;
		background-image: url("../../static/img/gouwuche.png");
		background-repeat: no-repeat;
		background-size: 45rpx;
	}
</style>